package Opter;

import Libray.Book;
import Libray.BookShelf;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xwl
 * Date: 2023-04-16
 * Time: 0:17
 */
public class QuestionOpter implements IOpter {
    // 查询方法
    public void opterFun(BookShelf bookShelf,String name) {
        // ret接收书的数量
        int ret = bookShelf.getBookNum();
        // books接收书架
        Book[] books = bookShelf.getBooks();
        for (int i = 0; i < ret; i++) {
            if (name.equals(books[i].getBookName())) {
                System.out.println(books[i].toString());
                break;
            } else if (i == ret - 1){
                System.out.println("该书暂未被收录");
            }
        }
    }
}
